package jianzhiOffer;

import java.util.Stack;

//剑指 Offer 09. 用两个栈实现队列
public class Num09_CQueue {
    //两个栈一个出栈，一个入栈
    private Stack<Integer> stack1;
    private Stack<Integer> stack2;

    public Num09_CQueue() {
        stack1 = new Stack<>();
        stack2 = new Stack<>();

    }

    public void appendTail(int value) {
        stack1.push(value);
    }
    public int deleteHead() {

        
        if (!stack2.isEmpty()){
            return stack2.pop();
        }else{
            while (!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
            return stack2.isEmpty()?-1:stack2.pop();
        }
    }

}
